import request from '@/utils/request'
import apiConfig from '@/api/config'
import qs from 'qs'

// 流程列表查询
export const getProcessList = params => {
  return request({
    url: `${apiConfig.businessApi}/processes`,
    method: 'get',
    params: params
  })
}

// 流程列表添加
export const insertProcess = data => {
  return request({
    url: `${apiConfig.businessApi}/processes`,
    method: 'post',
    data
  })
}
// 流程列表修改
export const updateProcess = data => {
  return request({
    url: `${apiConfig.businessApi}/processes`,
    method: 'put',
    data
  })
}
// 流程列表删除
export const deleteProcess = id => {
  return request({
    url: `${apiConfig.businessApi}/processes/${id}`,
    method: 'delete',
  })
}

// 节点列表查询
export const getNodeList = params => {
  return request({
    url: `${apiConfig.businessApi}/process-nodes`,
    method: 'get',
    params: params
  })
}
// 节点列表添加
export const insertNode = data => {
  return request({
    url: `${apiConfig.businessApi}/process-nodes`,
    method: 'post',
    data
  })
}
// 节点列表修改
export const updateNode = data => {
  return request({
    url: `${apiConfig.businessApi}/process-nodes`,
    method: 'put',
    data
  })
}
// 节点列表删除
export const deleteNode = id => {
  return request({
    url: `${apiConfig.businessApi}/process-nodes/${id}`,
    method: 'delete',
  })
}

// 流程列表查询
export const getConditionList = params => {
  return request({
    url: `${apiConfig.businessApi}/process-conditions`,
    method: 'get',
    params: params
  })
}
// 流程列表添加
export const updateCondition = (id, data) => {
  return request({
    url: `${apiConfig.businessApi}/process-conditions/batch/${id}`,
    method: 'post',
    data
  })
}
